from collections import deque

# 二维滑动窗口,单调队列
def solve():
    n, m, a, b = map(int, input().split())
    matrix = [list(map(int, input().split())) for _ in range(n)]

    # 第一步：处理每行的滑动窗口最小值（窗口大小b）
    row_min = [[0] * m for _ in range(n)]
    for i in range(n):
        q = deque()
        for j in range(m):
            while q and matrix[i][q[-1]] >= matrix[i][j]:
                q.pop()
            q.append(j)
            while q and j - q[0] + 1 > b:
                q.popleft()
            row_min[i][j] = matrix[i][q[0]]

    # 第二步：处理每行的滑动窗口最大值（窗口大小b）
    row_max = [[0] * m for _ in range(n)]
    for i in range(n):
        q = deque()
        for j in range(m):
            while q and matrix[i][q[-1]] <= matrix[i][j]:
                q.pop()
            q.append(j)
            while q and j - q[0] + 1 > b:
                q.popleft()
            row_max[i][j] = matrix[i][q[0]]

    # 第三步：处理每列的滑动窗口最小值（窗口大小a），基于row_min
    col_min = [[0] * m for _ in range(n)]
    for j in range(m):
        q = deque()
        for i in range(n):
            while q and row_min[q[-1]][j] >= row_min[i][j]:
                q.pop()
            q.append(i)
            while q and i - q[0] + 1 > a:
                q.popleft()
            col_min[i][j] = row_min[q[0]][j]

    # 第四步：处理每列的滑动窗口最大值（窗口大小a），基于row_max
    col_max = [[0] * m for _ in range(n)]
    for j in range(m):
        q = deque()
        for i in range(n):
            while q and row_max[q[-1]][j] <= row_max[i][j]:
                q.pop()
            q.append(i)
            while q and i - q[0] + 1 > a:
                q.popleft()
            col_max[i][j] = row_max[q[0]][j]

    # 计算结果
    ans = 0
    for i in range(a - 1, n):
        for j in range(b - 1, m):
            ans += col_min[i][j] * col_max[i][j]
    print(ans)

solve()